# Create your forms here.

from django import forms
from django.forms import ModelForm

from psd.register.models import Person, RegRecord, DateRecord, CruiseRecord, MatchRecord, MatchChoice, MatchQuestion, BreakRecord

from psd.register.psdcheckbox import *


class PersonForm(ModelForm):
    gender = PSDMultipleChoiceField(choices=getPSDCheckboxOptions("Gender"), widget=PSDCheckboxSelectMultiple, label="Gender")
#    seek_gender = PSDMultipleChoiceField(choices=getPSDCheckboxOptions("Gender"), widget=PSDCheckboxSelectMultiple, label="Gender Wanted")
    seek_gender = PSDMultipleChoiceWithPrefField(choices=getPSDCheckboxOptions("Gender"), widget=PSDPrefCheckboxWidget, label="Gender Preferred")
#    seek_gender = PSDPrefCheckboxWidget(choices=getPSDCheckboxOptions("Gender"), widget=PSDCheckboxSelectMultiple, label="Gender Wanted")
    age = forms.IntegerField(widget=forms.TextInput(attrs={'size': 5}))
    seek_age_min =  forms.IntegerField(widget=forms.TextInput(attrs={'size': 5}))
    seek_age_max =  forms.IntegerField(widget=forms.TextInput(attrs={'size': 5}))
    seek_kinkiness = forms.ChoiceField(choices=getPSDCheckboxOptions("Kinkinesses"), initial='EI')

    class Meta:
        model = Person

    def clean(self):
        cleaned_data = self.cleaned_data
         
        # Always return the full collection of cleaned data.
        return cleaned_data
    
    

class DateRecordForm(ModelForm):
    psdid = forms.CharField(widget=forms.TextInput(attrs={'side':8}))
    other_psdid = forms.CharField(widget=forms.TextInput(attrs={'side':8}))

    class Meta:
        model = DateRecord



class MatchRecordForm(ModelForm):
    psdid1 = forms.CharField(widget=forms.TextInput(attrs={'side':8}))
    psdid2 = forms.CharField(widget=forms.TextInput(attrs={'side':8}))
#    event = forms.CharField(max_length=10, blank=True)
#    match = forms.PositiveIntegerField(verbose_name="Likability")
#    gay_ok = forms.BooleanField(verbose_name="Gay Round Okay")
#    str_ok = forms.BooleanField(verbose_name="Straight Round Okay")

    class Meta:
        model = MatchRecord





        
    
class RegRecordForm(ModelForm):             
    location = PSDMultipleChoiceField(required=False, choices=getPSDCheckboxOptions("Location"), widget=PSDCheckboxSelectMultiple)
    nickname = forms.CharField(widget=forms.TextInput(attrs={'size': 25}))
    email = forms.EmailField()#(widget=forms.TextInput(attrs={'size': 25}))
    referred_by = forms.CharField(required=False, widget=forms.TextInput(attrs={'size': 45}))
    comments = forms.CharField(required=False, widget=forms.Textarea(attrs={'cols':40,'rows':3}))
    seek_fling = forms.ChoiceField(choices=getPSDCheckboxOptions("Flinginesses"), initial='EI')

    class Meta:
        model = RegRecord
#        exclude = ('people',)


class PostEmailForm(forms.Form):
    event_name = forms.CharField()
    subject = forms.CharField(widget=forms.TextInput( attrs={'size':80} ))
    body = forms.CharField(widget=forms.Textarea(attrs={'cols': 80, 'rows': 40}))
    send_matches = forms.BooleanField(required=False)
    really_send = forms.BooleanField(required=False)
    
TOPICS = (
    ('general', 'General'),
    ('matching', 'Matching'),
    ('ops', 'Food/Location/Timing'),
    ('site', 'PSD website'),
    ('other', 'Other'),
        )

class FeedbackForm(forms.Form):
    topic = forms.ChoiceField(required=False, choices=TOPICS)
    message = forms.CharField(required=False, widget=forms.Textarea(attrs={'cols':40,'rows':3}))
    email = forms.EmailField(required=False, label="Your address (optional)")
    psdid = forms.CharField(required=False, label="Your PSDID (optional)")



class NextSheetForm(forms.Form):
    psdid = forms.CharField(required=True, label="PSDID")


class ScheduleForm(forms.Form):
    INCLUDE_OPTIONS = ( ("NotNo", "Everyone that has not cancelled" ),
                        ("paid", "Folks marked as paid or pending" ),
                        ("In", "Folks checked off as here" ) )
    
    rounds = forms.IntegerField(widget=forms.TextInput(attrs={'size': 5}), initial=12)
    trials = forms.IntegerField(widget=forms.TextInput(attrs={'size': 5}), initial=1)
    include = forms.ChoiceField( choices=INCLUDE_OPTIONS )
   
   
class MultiBreakForm(forms.Form):
    reason = forms.CharField(widget=forms.TextInput(attrs={'size':50}), initial="hand break") 
    
class BreakForm(ModelForm):
    notes = forms.CharField(widget=forms.TextInput(attrs={'size':50}), required=False) 
    
    class Meta:
        model = BreakRecord
        
    
class CruiseForm(forms.Form):
    other_psdid = forms.CharField(required=True, label="OTHER PSDID")
        
    
